#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# :CREATED: [2018-04-26 Thu 21:35]
# :AUTHOR: zb
from models.base import Base, engine, db
from models.server import (
    Server,
    init_table,
    Url_address,
    app_path_map,
    )



def create_all():
    Base.metadata.create_all(engine)
    if not db.query(Server).first():
        path = r'data/server_list.csv'
        init_table(Server, path, coding='GBK')

    if not db.query(Url_address).first():
        path = r'data/url_address.csv'
        init_table(Url_address, path, coding='GBK')

    if not db.query(app_path_map).first():
        path = r'data/app_path_map.csv'
        init_table(app_path_map, path, coding='GBK')
        
    db.close()

if __name__ == '__main__':
    create_all()
